package entityBeans;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorType;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
//import javax.persistence.Transient;

@Entity
@DiscriminatorColumn(name="DISCRIMINATEUR_CONTACT", discriminatorType=DiscriminatorType.INTEGER)
@DiscriminatorValue("Contact")
public class Contact {
	private long id;
	private String firstName;
	private String secondName;
	private String email;
	private Address add;
	private Set<PhoneNumber> profiles;
	private Set<ContactGroup> books;

	public Contact(String firstName, String secondName, String email){
		this.firstName = firstName;
		this.secondName = secondName;
		this.email = email;
		this.profiles = new HashSet<PhoneNumber>();
		this.books = new HashSet<ContactGroup>();
	}
	
	public Contact(){
		this("", "", "");
	}
	
	@OneToOne
	public Address getAdd() {
		return add;
	}
	public void setAdd(Address add) {
		this.add = add;
	}
	@OneToMany(mappedBy="contact")
	public Set<PhoneNumber> getProfiles() {
		return profiles;
	}
	public void setProfiles(Set<PhoneNumber> profiles) {
		this.profiles = profiles;
	}
	@ManyToMany(mappedBy="contacts")
	public Set<ContactGroup> getBooks() {
		return books;
	}
	public void setBooks(Set<ContactGroup> books) {
		this.books = books;
	}
	public String getFirstName() {
		return firstName;
	}
	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}
	public String getSecondName() {
		return secondName;
	}
	public void setSecondName(String secondName) {
		this.secondName = secondName;
	}
	public String getEmail() {
		return email;
	}
	public void setEmail(String email) {
		this.email = email;
	}
	
	@Id@GeneratedValue(strategy=GenerationType.AUTO)
	public long getId() {
		return id;
	}
	public void setId(long id) {
		this.id = id;
	}
	
	

}
